#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from multiprocessing import Process, Queue

q = Queue(3)

"""
q.put("hello")
q.put("world")
q.put("world2")
print("--->  maxsize=3 阻塞")
# q.put("world3")

print(q.get())
print(q.get())
print(q.get())
print(q.get())      # 当队列中只有3个，取出也会被阻塞
"""

q.put("hello", block=True, timeout=3)
q.put("hello", block=True, timeout=3)
q.put("hello", block=True, timeout=3)
# q.put("hello", block=True, timeout=3)   # raise Full
print(q.get(block=True, timeout=3))
print(q.get(block=True, timeout=3))
print(q.get(block=True, timeout=3))
print(q.get(block=True, timeout=3))

# q.put_nowait("hello")
# q.put_nowait("hello")
# q.put_nowait("hello")
# q.put_nowait("hello")  # 等于 q.put("hello", block=True, timeout=3)
